package com.ruoyi.system.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.IndsvrSsoAppUserMapRoot;
import com.ruoyi.system.service.IIndsvrSsoAppUserMapRootService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账号分配Controller
 * 
 * @author indsvr
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/system/IndsvrSsoAppUserMapRoot")
public class IndsvrSsoAppUserMapRootController extends BaseController
{
    @Autowired
    private IIndsvrSsoAppUserMapRootService indsvrSsoAppUserMapRootService;

    /**
     * 查询账号分配列表
     */
    @PreAuthorize("@ss.hasPermi('system:IndsvrSsoAppUserMapRoot:list')")
    @GetMapping("/list")
    public TableDataInfo list(IndsvrSsoAppUserMapRoot indsvrSsoAppUserMapRoot)
    {
        startPage();
        List<IndsvrSsoAppUserMapRoot> list = indsvrSsoAppUserMapRootService.selectIndsvrSsoAppUserMapRootList(indsvrSsoAppUserMapRoot);
        return getDataTable(list);
    }

    /**
     * 导出账号分配列表
     */
    @PreAuthorize("@ss.hasPermi('system:IndsvrSsoAppUserMapRoot:export')")
    @Log(title = "账号分配", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IndsvrSsoAppUserMapRoot indsvrSsoAppUserMapRoot)
    {
        List<IndsvrSsoAppUserMapRoot> list = indsvrSsoAppUserMapRootService.selectIndsvrSsoAppUserMapRootList(indsvrSsoAppUserMapRoot);
        ExcelUtil<IndsvrSsoAppUserMapRoot> util = new ExcelUtil<IndsvrSsoAppUserMapRoot>(IndsvrSsoAppUserMapRoot.class);
        util.exportExcel(response, list, "账号分配数据");
    }

    /**
     * 获取账号分配详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:IndsvrSsoAppUserMapRoot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(indsvrSsoAppUserMapRootService.selectIndsvrSsoAppUserMapRootById(id));
    }

    /**
     * 新增账号分配
     */
    @PreAuthorize("@ss.hasPermi('system:IndsvrSsoAppUserMapRoot:add')")
    @Log(title = "账号分配", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IndsvrSsoAppUserMapRoot indsvrSsoAppUserMapRoot)
    {
        return toAjax(indsvrSsoAppUserMapRootService.insertIndsvrSsoAppUserMapRoot(indsvrSsoAppUserMapRoot));
    }

    /**
     * 修改账号分配
     */
    @PreAuthorize("@ss.hasPermi('system:IndsvrSsoAppUserMapRoot:edit')")
    @Log(title = "账号分配", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IndsvrSsoAppUserMapRoot indsvrSsoAppUserMapRoot)
    {
        return toAjax(indsvrSsoAppUserMapRootService.updateIndsvrSsoAppUserMapRoot(indsvrSsoAppUserMapRoot));
    }

    /**
     * 删除账号分配
     */
    @PreAuthorize("@ss.hasPermi('system:IndsvrSsoAppUserMapRoot:remove')")
    @Log(title = "账号分配", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(indsvrSsoAppUserMapRootService.deleteIndsvrSsoAppUserMapRootByIds(ids));
    }
}
